<?php
header("Content-Type:text/html;charset=utf-8");
$url = "http://".$_SERVER['HTTP_HOST'];
header("Access-Control-Allow-Origin: ".$url); // 允许a.com发起的跨域请求  
//如果需要设置允许所有域名发起的跨域请求，可以使用通配符 *  
header("Access-Control-Allow-Origin: *"); // 允许任意域名发起的跨域请求  
header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With');  
date_default_timezone_set('Asia/Shanghai');

$con = mysqli_connect("localhost","root","root","ultrax");
// 检测连接
if (mysqli_connect_errno())
{
    die("连接失败: " . mysqli_connect_error());
}
if(!$_POST){ 
	echo json_encode(['code'=>0,'msg'=>'请求错误']);
	exit;
}
$id = $_POST['id'];
$sql = "select * from pre_common_block_shareurl where id = '{$id}'";
$result = mysqli_query($con,$sql);
$res = mysqli_fetch_array($result,MYSQLI_ASSOC);
if($res){
     echo json_encode(['code'=>1,'data'=>$res,'msg'=>'成功']);
}else{
    echo json_encode(['code'=>0,'msg'=>'不存在']);
    exit;
}
mysqli_close($con);
?>